﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;

#nullable disable

namespace NetByDocker.Domain.Npgsql.Migrations
{
    /// <inheritdoc />
    public partial class Initial : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.EnsureSchema(
                name: "example");

            migrationBuilder.CreateTable(
                name: "group",
                schema: "example",
                columns: table => new
                {
                    id = table.Column<long>(type: "bigint", maxLength: 36, nullable: false, comment: "主键")
                        .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
                    name = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false, defaultValue: "", comment: "班级名称"),
                    creater = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false, defaultValue: "", comment: "创建人"),
                    create_time = table.Column<DateTime>(type: "timestamp without time zone", nullable: false, comment: "创建时间"),
                    modifyer = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false, defaultValue: "", comment: "最后修改人"),
                    modify_time = table.Column<DateTime>(type: "timestamp without time zone", nullable: false, comment: "最后修改时间"),
                    deleted = table.Column<bool>(type: "boolean", nullable: false, comment: "是否删除"),
                    disabled = table.Column<bool>(type: "boolean", nullable: false, comment: "是否禁用")
                },
                constraints: table =>
                {
                    table.PrimaryKey("pk_group", x => x.id);
                });

            migrationBuilder.CreateTable(
                name: "score",
                schema: "example",
                columns: table => new
                {
                    id = table.Column<long>(type: "bigint", maxLength: 36, nullable: false, comment: "主键")
                        .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
                    course_name = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false, defaultValue: "", comment: "课程名"),
                    grade = table.Column<int>(type: "integer", nullable: false, defaultValue: 0, comment: "成绩"),
                    user_id = table.Column<long>(type: "bigint", nullable: false, comment: "用户ID"),
                    create_time = table.Column<DateTime>(type: "timestamp without time zone", nullable: false, comment: "创建时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("pk_score", x => x.id);
                });

            migrationBuilder.CreateTable(
                name: "user",
                schema: "example",
                columns: table => new
                {
                    id = table.Column<long>(type: "bigint", maxLength: 36, nullable: false, comment: "主键")
                        .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
                    account = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false, comment: "账号标识"),
                    pass_word = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false, comment: "密码"),
                    name = table.Column<string>(type: "text", nullable: false),
                    sex = table.Column<int>(type: "integer", nullable: false, comment: "性别"),
                    credit = table.Column<double>(type: "double precision", nullable: false),
                    group_id = table.Column<long>(type: "bigint", nullable: false),
                    creater = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false, defaultValue: "", comment: "创建人"),
                    create_time = table.Column<DateTime>(type: "timestamp without time zone", nullable: false, comment: "创建时间"),
                    modifyer = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false, defaultValue: "", comment: "最后修改人"),
                    modify_time = table.Column<DateTime>(type: "timestamp without time zone", nullable: false, comment: "最后修改时间"),
                    deleted = table.Column<bool>(type: "boolean", nullable: false, comment: "是否删除"),
                    disabled = table.Column<bool>(type: "boolean", nullable: false, comment: "是否禁用")
                },
                constraints: table =>
                {
                    table.PrimaryKey("pk_user", x => x.id);
                });
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "group",
                schema: "example");

            migrationBuilder.DropTable(
                name: "score",
                schema: "example");

            migrationBuilder.DropTable(
                name: "user",
                schema: "example");
        }
    }
}
